/* @(#)GSOperLogDAO.java    
*
* Project: BUS
*
* Modify Information:
* =============================================================================
*   Author       Date       Description
*   ------------ ---------- ---------------------------------------------------
*   Simonyi Peng 2006-2-7    建立
*
* Copyright Notice:
* =============================================================================
*    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
*        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
*        Haidian District, Beijing ,100081, China All rights reserved.
*
*    This software is the confidential and proprietary information of
*        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
*        You shall not disclose such Confidential Information and shall use it
*        only in accordance with the terms of the license agreement you entered
*        into with HiTRUST.
*
* Warning:
* =============================================================================
* 
*/
package com.hitrust.gs.dao;

import java.text.SimpleDateFormat;
import java.util.Date;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.GenRandNum;
import com.hitrust.gs.util.exception.GSException;
;
 

public class GSOperLogDAO extends GSBaseDAO {
    

    private void executeLog(String operDate,String operId,String funcId,String content) throws GSException {
        GSOperLogDAO dao = new GSOperLogDAO();
        String sql = "insert into GS_OPER_LOG (GS_OPER_LOG_ID,GS_OPER_DATE,GS_FUNC_ID,GS_OPER_ID,GS_OPER_CONTENT) values (?,?,?,?,?)";
        
        try{
            String logId = GenRandNum.genDTRandNum();
            
            Object[]  object = new Object[]{logId,operDate,funcId,operId,content};
            dao.executeUpdate(sql,object);
            
            
        }catch(Exception e){
            throw new GSException(GSException.E00001,GSException.E00001_MSG);
        }
    }
    

    public void log(String operId,String funcId,String[][] args) throws GSException {
        String operDate = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis()));
        StringBuffer sb = new StringBuffer("");
        for(int i=0;i<args.length;i++){
            sb.append(args[i][0]).append("=").append(args[i][1]).append("&");
        }
        executeLog(operDate,operId,funcId,sb.toString());
    }
}
